﻿; (function () {

    'use strict';

    window.ValuesSet = function ValuesSet() {
        this.has = [];
        for (var i = 0; i < 10; i++) {
            this.has[i] = false;
        }
        this.values = [];
        this.count = 0;
        this._areValuesClean = true;
    }

    ValuesSet.prototype.add = function (value) {
        if (this.has[value])
            return false;

        this.has[value] = true;
        this.values.push(value);
        this.count++;
        return true;
    };

    ValuesSet.prototype.addRange = function (values) {
        var added = false;
        for (var i = 0, len = values.length; i < len; i++) {
            added |= this.add(values[i]);
        }
        return added;
    };


    ValuesSet.prototype.remove = function (value) {
        if (!this.has[value])
            return false;

        this.has[value] = false;
        this.values.remove(value);
        this.count--;
        return true;
    };

    ValuesSet.prototype.clear = function () {
        for (var i = 0; i < 10; i++) {
            this.has[i] = false;
        }

        this.values.clear();
        this.count = 0;
    };

    ValuesSet.prototype.getMask = function () {
        var mask = 0;
        for (var i = 0; i < 10; i++) {
            if (this.has[i])
                mask |= 1 << i;
        }

        return mask;
    };

}(window));
